home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Apple Script / OSAX / Jon’s Commands / Jon’s Commands Read Me < prev   
Text File  |  1994-01-23  |  6KB  |  101 lines

  1. Jon’s Commands 1.0b4
  2. Copyright 1993 by Jon Pugh
  3. (415) 691-6643
  4. jonpugh@netcom.com
  5.  
  6. Free for noncommercial use.  Contact me for a simple cheap license if you wish to include any or all of these as part of a software solution that you sell.  I can customize the package to include only specific commands.
  7.  
  8. This AppleScript Scripting Addition provides AppleScript and all scriptable and Apple Event aware applications with added functionality.  To examine the AppleScript syntax of each of these commands, simply drag Jon’s Commands onto the Script Editor or use the Open Dictionary command to open it.  To install it, simply drop it into the Scripting Additions folder which is inside your Extensions folder.
  9.  
  10. Jon’s Commands includes these commands:
  11.    deleteFile - delete a single file
  12.    renameFile - rename a file
  13.    moveFile - move a file to a different folder
  14.    sound volume - get the volume setting
  15.    set sound volume to - set the volume setting
  16.    clipboard info - get a list of data on the clipboard
  17.    set the clipboard to - put data on the clipboard
  18.    the clipboard - get data from the clipboard
  19.    execute FKEY - run an FKEY resource
  20.    screen list - describe the monitor configuration
  21.    finder selection - return the Finder’s selection
  22.    keys pressed - get a list of pressed keys
  23.    machine environment - get info about the machine
  24.    play sound - play sound resources, files and descriptors
  25.    run script resource - run an ‘Scpt’ or ‘scpt’ resource
  26.    free memory - return the free memory available
  27.    the ticks - return the current value of tickCount
  28.  
  29. Jon’s Commands includes these objects:
  30.    picture - for getting them off the clipboard
  31.    sound - for getting them off the clipboard & playing them
  32.    screen info - for describing the monitors
  33.    environment info - for describing the machine
  34.  
  35. Notes for specific commands:
  36.  
  37. Finder Selection:
  38.  
  39. This Addition gets the Finder’s selected files and folders. This only works with Finder 7.0, 7.0.1, 7.1 & 7.1.1. Using it with any other Finder will cause it to fail.  Hopefully it won’t crash, but it probably won’t work.  I only check for the system version (Gestalt doesn’t tell the Finder version, only the System version) so using a different Finder will definately cause problems.
  40.  
  41. You can place script applications in the Apple Menu Items folder and use the finder selection to have your script operate on the selected files.  Way cool.
  42.  
  43. DeleteFile, MoveFile & RenameFile:
  44.  
  45. These commands only work on single files.  DeleteFile is permanent and immediate.  Be very careful with it.  I recommend using “moveFile foo to (path to trash)” or the FinderLib if you are at all worried or inclined toward cautiousness.
  46.  
  47. execute FKEY:
  48.  
  49. This loads the FKEY resource and jumps to it. It does not press command-shift-N, so it will not trigger QuicKeys macros or any function which patches things to run at FKEY-like key combinations.
  50.  
  51. keys pressed & machine information:
  52.  
  53. Keys Pressed returns the GetKey info in the form of a list of key names in string form.
  54.  
  55. Machine info returns a keyworded record object of common machine information. from Gestalt.
  56.  
  57. Both of these use STR# resources if you are inclined to localize them.  The machine info is a subset of the available Gestalt selectors.  If you have need of others, let me know and we might be able to include them in a future version, although you can get raw information for any gestalt selector directly.
  58.  
  59. clipboard info, the clipboard & set the clipboard to:
  60.  
  61. All of these can manage multiple data types.  Styled text is the default data type, with plain text (known as string) as the backup.  International text is also supported, as are a lot of other data formats.  Almost any resource type can be manipulated in AppleScript as an AEDesc in applications. Pictures and sounds are also popular to move around.
  62.  
  63. sound volume & set sound volume to:
  64.  
  65. Both of these use a number between 0 and 7 for the volume, just like everyone else.
  66.  
  67. play sound:
  68.  
  69. This can play sound (‘snd ’) resources installed in the system or the current open files by either name or id number. It can also play sound resources out of files and out of AppleScript variables (typically accessed via the clipboard). You cannot interrupt a sound in progress in this version and the sounds are play synchronously.  This command is a small improvement on the sample code from the Language Reference Manual.
  70.  
  71. run script resource:
  72.  
  73. This matches the AppleScript Run Script command but works on resources instead of files.  This allows you to bundle several scripts (typically from other OSA components such as QuicKeys) into a single script file or application. I’ve used it to place the ‘scpt’ resources from QuicKeys scripts into an applet and run them from there.
  74.  
  75. There is a problem with having more than 1 ‘scpt’ resource per file and that is the Script Editor.  It finds the script to display by using Get1IndResource('scpt', 1) which can return the wrong resource if you have several. If you are literate with ResEdit you can make sure the poper script resource is last in the file, but that’s less certain than the other technique I recommend, which is to change the script resource’s type to ‘Scpt’ which is not recognized by the Script Editor.  You need to copy the script resource as hex data and paste it into a new empty ‘Scpt’ resource.  This way involves no conflicts.  Another choice is to use my RunScript MPW tool which allows you to create script resources of any type and id.  This makes it simple to create a script application which combines AppleScript and QuicKeys scripts.
  76.  
  77. You can reference script resources by name or number.
  78.  
  79. free memory:
  80.  
  81. This returns the current value of the function FreeMem.  It shows the amount of free memory available in the current application’s current heap.  Useful for finding memory leaks.
  82.  
  83. the ticks:
  84.  
  85. This returns the current value of TickCount.  This is useful for timing functions from scripts.
  86.  
  87.  
  88. Version History:
  89.  
  90. 1.0b1 - first public release
  91. 1.0b2 - fixed key name in “keys pressed” for PowerBook keyboard.
  92. 1.0b3 - added 7.1.1 to version check for “finder selection”.
  93. 1.0b4 - added “run script resource” command.
  94. 1.0b5 - added “free memory” and “the ticks” commands.
  95. 1.0 - official release.
  96.  
  97. Feel free to write with questions, comments or suggestions.
  98.  
  99. Jon Pugh
  100. (415) 691-6643
  101. jonpugh@netcom.com